/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mti.javashare.webservices;

import com.mti.javashare.beans.File;
import com.mti.javashare.beans.User;
import java.io.InputStream;
import java.util.Collection;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.ws.rs.*;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Toto
 */
@WebService
@Path("/File/")
public interface IFileWebService
{
    @GET
    @Path("/getById/{id}")
    @WebMethod(operationName = "getById")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    File getById(
        @WebParam(name = "id")
        @PathParam(value = "id")
        int id);

    @GET
    @Path("/getByName/{name}")
    @WebMethod(operationName = "getByName")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    File getByName(
        @WebParam(name = "name")
        @PathParam(value = "name")
        String name);

    @GET
    @Path("/getAll")
    @WebMethod(operationName = "getAll")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    Collection<File> getAll();

    @POST
    @Path("/add")
    @Consumes("multipart/form-data")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
    String add(
        @Multipart(value = "iduser")
        int iduser,
        @Multipart(value = "filename")
        String filename,
        @Multipart(value = "description")
        String description,
        @Multipart("file")
        InputStream file);
    
    @GET
    @Path("/downloadById/{id}")
    @WebMethod(operationName = "downloadById")
    @Produces("application/octet-stream")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    java.io.File downloadById(
        @WebParam(name = "id")
        @PathParam(value = "id")
        int id);
    
    @GET
    @Path("/download/{name}")
    @WebMethod(operationName = "download")
    @Produces("application/octet-stream")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    java.io.File download(
        @WebParam(name = "name")
        @PathParam(value = "name")
        String name);

    @GET
    @Path("/update/{id}/{name}/{description}/{iduser}")
    @WebMethod(operationName = "update")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
    void update(
        @WebParam(name = "id")
        @PathParam(value = "id")
        int id,
        @WebParam(name = "name")
        @PathParam(value = "name")
        String name,
        @WebParam(name = "description")
        @PathParam(value = "description")
        String description,
        @WebParam(name = "iduser")
        @PathParam(value = "iduser")
        int iduser);
    
    @GET
    @Path("/remove/{id}")
    @WebMethod(operationName = "remove")
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
    void remove(
        @WebParam(name = "id")
        @PathParam(value = "id")
        int id);
}
